<script setup lang="ts">
// 导入需要的组件和hooks
import { ref, onMounted } from 'vue'

// 轮播图数据
const carouselItems = ref([
  {
    title: '欢迎使用现代化系统',
    description: '专业的解决方案，为您的业务提供全方位支持',
    image: 'https://images.unsplash.com/photo-1542744173-8e7e53415bb0?auto=format&fit=crop&q=80',
    buttonText: '立即开始',
    buttonLink: '#start'
  },
  {
    title: '高效稳定的服务',
    description: '采用最新技术栈，确保系统性能优异且稳定可靠',
    image: 'https://images.unsplash.com/photo-1551288049-bebda4e38f71?auto=format&fit=crop&q=80',
    buttonText: '了解更多',
    buttonLink: '#features'
  },
  {
    title: '个性化定制方案',
    description: '根据您的需求提供量身定制的解决方案',
    image: 'https://images.unsplash.com/photo-1561070791-2526d30994b5?auto=format&fit=crop&q=80',
    buttonText: '联系我们',
    buttonLink: '#contact'
  }
])

// 轮播状态
const currentSlide = ref(0)

// 功能卡片数据
const features = [
  {
    icon: '🚀',
    title: '高效性能',
    description: '采用先进技术架构，确保系统运行流畅，响应迅速'
  },
  {
    icon: '🔒',
    title: '安全可靠',
    description: '多重安全机制保障您的数据安全，防止未授权访问'
  },
  {
    icon: '📱',
    title: '响应式设计',
    description: '完美适配各种设备，无论是电脑、平板还是手机'
  },
  {
    icon: '⚙️',
    title: '灵活配置',
    description: '丰富的配置选项，满足不同场景的业务需求'
  }
]

// 启动轮播
const startCarousel = () => {
  setInterval(() => {
    currentSlide.value = (currentSlide.value + 1) % carouselItems.value.length
  }, 5000)
}

// 切换轮播
const goToSlide = (index: number) => {
  currentSlide.value = index
}

onMounted(() => {
  startCarousel()
})
</script>

<template>
  <div class="home-page">
    <!-- 轮播图区域 -->
    <section class="carousel">
      <div class="carousel-container" :style="{ transform: `translateX(-${currentSlide * 100}%)` }">
        <div 
          v-for="(item, index) in carouselItems" 
          :key="index" 
          class="carousel-slide"
          :style="{ backgroundImage: `url(${item.image})` }"
        >
          <div class="carousel-content">
            <h1>{{ item.title }}</h1>
            <p>{{ item.description }}</p>
            <a :href="item.buttonLink" class="btn btn-primary">{{ item.buttonText }}</a>
          </div>
        </div>
      </div>
      <!-- 轮播指示器 -->
      <div class="carousel-indicators">
        <button 
          v-for="(item, index) in carouselItems" 
          :key="index"
          class="indicator"
          :class="{ active: index === currentSlide }"
          @click="goToSlide(index)"
        ></button>
      </div>
    </section>

    <!-- 功能特点区域 -->
    <section class="features-section" id="features">
      <div class="section-header">
        <h2>核心功能</h2>
        <p>我们提供全面的功能，满足您的各种业务需求</p>
      </div>
      <div class="features-grid">
        <div 
          v-for="(feature, index) in features" 
          :key="index" 
          class="card feature-card"
        >
          <div class="feature-icon">{{ feature.icon }}</div>
          <h3>{{ feature.title }}</h3>
          <p>{{ feature.description }}</p>
        </div>
      </div>
    </section>

    <!-- 关于我们简介 -->
    <section class="about-preview">
      <div class="card about-card">
        <div class="about-content">
          <h2>关于我们</h2>
          <p>我们是一支专业的团队，致力于为客户提供高质量的解决方案。多年来，我们积累了丰富的行业经验，能够为不同规模的企业提供定制化服务。</p>
          <a href="/about" class="btn btn-secondary">了解更多</a>
        </div>
        <div class="about-image">
          <img src="https://images.unsplash.com/photo-1552664730-d307ca884978?auto=format&fit=crop&q=80" alt="团队照片">
        </div>
      </div>
    </section>

    <!-- 服务模块 -->
    <section class="services-section" id="services">
      <div class="section-header">
        <h2>我们的服务</h2>
        <p>提供全方位的服务支持，助您的业务蓬勃发展</p>
      </div>
      <div class="services-grid">
        <div class="card service-card">
          <h3>咨询服务</h3>
          <p>专业的咨询团队，为您提供业务分析和优化建议</p>
        </div>
        <div class="card service-card">
          <h3>技术支持</h3>
          <p>7x24小时的技术支持，确保系统稳定运行</p>
        </div>
        <div class="card service-card">
          <h3>培训课程</h3>
          <p>系统使用培训，帮助您的团队快速上手</p>
        </div>
      </div>
    </section>

    <!-- 联系我们模块 -->
    <section class="contact-section" id="contact">
      <div class="card contact-card">
        <div class="section-header">
          <h2>联系我们</h2>
          <p>如有任何问题或需求，请随时与我们联系</p>
        </div>
        <div class="contact-info">
          <div class="contact-item">
            <span class="contact-icon">📞</span>
            <span>400-123-4567</span>
          </div>
          <div class="contact-item">
            <span class="contact-icon">✉️</span>
            <span>contact@example.com</span>
          </div>
          <div class="contact-item">
            <span class="contact-icon">📍</span>
            <span>北京市朝阳区科技园A座1001室</span>
          </div>
        </div>
      </div>
    </section>
  </div>
</template>

<style scoped>
.home-page {
  width: 100%;
}

/* 轮播图样式 */
.carousel {
  position: relative;
  width: 100%;
  height: 600px;
  overflow: hidden;
  margin-bottom: 60px;
}

.carousel-container {
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.5s ease;
}

.carousel-slide {
  flex: 0 0 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  position: relative;
}

.carousel-slide::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.8) 0%, rgba(118, 75, 162, 0.8) 100%);
  z-index: 1;
}

.carousel-content {
  position: relative;
  z-index: 2;
  color: white;
  max-width: 800px;
  margin-left: 100px;
}

.carousel-content h1 {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 20px;
  line-height: 1.2;
}

.carousel-content p {
  font-size: 18px;
  margin-bottom: 30px;
  opacity: 0.9;
}

.carousel-indicators {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 15px;
  z-index: 3;
}

.indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.5);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.indicator.active {
  background-color: white;
  width: 30px;
  border-radius: 6px;
}

/* 通用标题样式 */
.section-header {
  text-align: center;
  margin-bottom: 50px;
}

.section-header h2 {
  font-size: 32px;
  font-weight: 700;
  color: #333;
  margin-bottom: 15px;
  position: relative;
  display: inline-block;
}

.section-header h2::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 4px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 2px;
}

.section-header p {
  font-size: 16px;
  color: #666;
  max-width: 600px;
  margin: 0 auto;
}

/* 功能卡片样式 */
.features-section {
  margin-bottom: 80px;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 30px;
}

.feature-card {
  text-align: center;
  padding: 30px;
}

.feature-icon {
  font-size: 48px;
  margin-bottom: 20px;
}

.feature-card h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 15px;
  color: #333;
}

.feature-card p {
  color: #666;
  font-size: 16px;
}

/* 关于我们预览样式 */
.about-preview {
  margin-bottom: 80px;
}

.about-card {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  align-items: center;
}

.about-content {
  flex: 1;
  min-width: 300px;
}

.about-content h2 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #333;
}

.about-content p {
  font-size: 16px;
  color: #666;
  margin-bottom: 30px;
  line-height: 1.8;
}

.about-image {
  flex: 1;
  min-width: 300px;
}

.about-image img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* 服务模块样式 */
.services-section {
  margin-bottom: 80px;
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
}

.service-card {
  text-align: center;
  padding: 30px;
}

.service-card h3 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 15px;
  color: #333;
}

.service-card p {
  color: #666;
  font-size: 16px;
}

/* 联系我们样式 */
.contact-section {
  margin-bottom: 60px;
}

.contact-card {
  text-align: center;
  padding: 40px;
}

.contact-info {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 40px;
  margin-top: 30px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 16px;
}

.contact-icon {
  font-size: 24px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .carousel {
    height: 400px;
  }
  
  .carousel-content {
    margin-left: 30px;
    margin-right: 30px;
    text-align: center;
  }
  
  .carousel-content h1 {
    font-size: 32px;
  }
  
  .carousel-content p {
    font-size: 16px;
  }
  
  .section-header h2 {
    font-size: 28px;
  }
  
  .about-content h2 {
    font-size: 28px;
  }
  
  .contact-info {
    flex-direction: column;
    gap: 20px;
  }
}
</style>
